using System;
using System.Web.UI;
using System.ComponentModel;
using System.Drawing;
using WebChart.Design;

namespace WebChart
{
	[PersistenceMode(PersistenceMode.InnerProperty), TypeConverter(typeof(ExpandableObjectConverter))]
	public class ChartText
	{
		// Fields
		private static Font defaultFont = new Font("Tahoma", 8f);
		private Font font;
		private Color foreColor;
		private StringFormat stringFormat;
		private string text;

		// Methods
		public ChartText()
		{
			this.text = string.Empty;
			this.font = defaultFont;
			this.foreColor = Color.Black;
			this.stringFormat = new StringFormat();
			this.stringFormat.Alignment = StringAlignment.Center;
			this.stringFormat.FormatFlags = StringFormatFlags.LineLimit;
		}

		public ChartText(StringFormat format)
		{
			this.text = string.Empty;
			this.font = defaultFont;
			this.foreColor = Color.Black;
			this.stringFormat = format;
		}

		public override string ToString()
		{
			return this.text;
		}

		// Properties
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
		public static Font DefaultFont
		{
			get
			{
				return defaultFont;
			}
			set
			{
				defaultFont = value;
			}
		}

		[Category("Appearance"), DefaultValue(typeof(Font), "Tahoma, 8pt"), NotifyParentProperty(true)]
		public Font Font
		{
			get
			{
				return this.font;
			}
			set
			{
				this.font = value;
			}
		}

		[NotifyParentProperty(true), DefaultValue(typeof(Color), "Black"), Category("Appearance")]
		public Color ForeColor
		{
			get
			{
				return this.foreColor;
			}
			set
			{
				this.foreColor = value;
			}
		}

		[Browsable(true), DefaultValue((string) null), PersistenceMode(PersistenceMode.Attribute), TypeConverter(typeof(StringFormatConverter)), NotifyParentProperty(true)]
		public StringFormat StringFormat
		{
			get
			{
				return this.stringFormat;
			}
			set
			{
				this.stringFormat = value;
			}
		}

		[Category("Appearance"), NotifyParentProperty(true), DefaultValue("")]
		public string Text
		{
			get
			{
				return this.text;
			}
			set
			{
				this.text = value;
			}
		}
	}
}
